/*
 * Antonio Canabrava Fraideinberze 7152292
 * Lucas Avelino Sodre Santos      7239086
 * Pedro Rael Garcia               7153021
 */

/*
 * Algorithm of Sieve of Eratosthenes Sequential
 */
#include "sieve.h"

/*
 * Calculate the Sieve of Erathostenes from 2 to LAST_PRIME
 */
void
calc_sieve(char *sieve)
{
    int i;
    int j;

    for(i = 0; i <= LAST_PRIME; i++)
        sieve[i] = 'y';

    for(i = 2; i <= LAST_PRIME; i++)
        if(sieve[i] == 'y')
            for(j = i * i; j <= LAST_PRIME; j += i)
                sieve[j] = 'n';
}

/*
 * Print the Sieve of Erathostenes from 2 to LAST_PRIME
 */
void
print(char *sieve)
{
    int i;

    for(i = 2; i <= LAST_PRIME; i++)
        if(sieve[i] == 'y')
            printf("%d ", i);
}
